package com.superteam.zzl.view.fragment;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.superteam.zzl.activity.R;
import com.superteam.zzl.activity.databinding.FragmentMainMyDynamicBinding;
import com.superteam.zzl.adapter.MyDynamicFragmentAdapter;


import java.util.ArrayList;
import java.util.List;


public class MainMyDynamicFragment extends com.superteam.zzl.view.BaseFragment {

    private FragmentMainMyDynamicBinding db;
    private List<Fragment> list;
    private MyDynamicFragmentAdapter adapter;

    public static MainMyDynamicFragment getInstance(String type) {
        Bundle bundle = new Bundle();
        bundle.putString("type", type);
        MainMyDynamicFragment fragment = new MainMyDynamicFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MainDynamicFragment mainDynamicFragment = new MainDynamicFragment();
        MessageFragment messageFragment = new MessageFragment();
        list = new ArrayList<Fragment>();
        list.add(mainDynamicFragment);
        list.add(messageFragment);
        String[] strings = getActivity().getResources().getStringArray(R.array.strings);
        adapter = new MyDynamicFragmentAdapter(getChildFragmentManager(), list, strings);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        db = DataBindingUtil.inflate(inflater, R.layout.fragment_main_my_dynamic, container, false);
        db.vp.setAdapter(adapter);
        db.tl.setupWithViewPager(db.vp);
        return db.getRoot();
    }



}
